package com.fmi.chesstern.pieces;

import java.util.ArrayList;

import com.fmi.chesstern.gameboard.GameBoard;
import com.fmi.chesstern.gameboard.GameField;
import com.fmi.chesstern.strategy.IGameStrategy;

public abstract class ChessPiece {

	protected IGameStrategy strategy;
	protected PieceType type;
	protected PieceColor color;

	public PieceColor getColor() {
		return color;
	}

	public void setColor(PieceColor color) {
		this.color = color;
	}

	protected ChessPiece(IGameStrategy strat, PieceType pieceType, PieceColor color) {
		this.strategy = strat;
		this.type = pieceType;
		this.color = color;
	}
	
	public abstract ArrayList<GameField> getValidMoves(GameField currentPosition, GameBoard board);
	
	public PieceType getType() {
		return type;
	}

	public void setType(PieceType type) {
		this.type = type;
	}
	
	public IGameStrategy getStrategy() {
		return strategy;
	}

	public void setStrategy(IGameStrategy strategy) {
		this.strategy = strategy;
	}

	public enum PieceColor {
		WHITE, BLACK;
		
		public static PieceColor getOppositeColor(PieceColor color) {
			PieceColor oppositeColor = null;
			if (color == PieceColor.WHITE) {
				oppositeColor = PieceColor.BLACK;
			} else if (color == PieceColor.BLACK) {
				oppositeColor = PieceColor.WHITE;
			}
			return oppositeColor;
		}
	}
	
	public enum PieceType {
		PAWN("pawn"), KING("king"), ROOK("rook"), QUEEN("queen"), KNIGHT("knight"), BISHOP("bishop");
		
		private String name;
		
		private PieceType(String name) {
			this.name = name;
		}
		
		public String getName() {
			return name;
		}
		
		public String toString() {
			return getName();
		}
	}
}
